var fs = require('fs')
function readFile_promise(path) {
  return new Promise((resolve, reject) => {
    fs.readFile(path, (err, data) => {
      if (err) {
        reject(new Error('Error'))
      } else {
        resolve(data.toString())
      }
    })
  })
}
function *Generator() {
  yield readFile_promise('../bar.txt')
  return
}
var gen = Generator()
gen.next().value.then(res => console.log(res)) // bar bar bar bar
          .catch(err => console.log(err))







function *gen_() {
  var result = yield readFile_promise('../bar.txt')
  console.log(result)
  var result2 = yield readFile_promise('../baz.txt')
  console.log(result2)
}
var g = gen_()
var result = g.next()
result.value.then(res => {
  console.log('res________', res)
  g.next(res).value.then(data => {
    console.log('data_____', data)
    g.next(data)
  })
})